package jpg1980.gttunes.actions;

import java.util.List;

import jpg1980.gttunes.beans.Car;
import jpg1980.gttunes.beans.Manufacturer;
import jpg1980.gttunes.beans.TuneBasic;
import jpg1980.gttunes.dao.CarDao;
import jpg1980.gttunes.dao.DaoFactory;
import jpg1980.gttunes.dao.ManufacturerDao;
import jpg1980.gttunes.dao.TuneBasicDao;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionSupport;

public class CarAction extends ActionSupport
{
	private static final long serialVersionUID = 1L;

	static Logger logger = Logger.getLogger(CarAction.class);

	List<Car> carList;
	String manufacturerName;

	public String jsonList()
	{
		CarDao carDao = DaoFactory.getDaoFactory().getCarDao();
		carList = carDao.readAll();

		return "json_list";
	}
	
	public String jsonListByManufacturer()
	{
		Manufacturer manufacturer = new Manufacturer(manufacturerName);
		CarDao carDao = DaoFactory.getDaoFactory().getCarDao();
		carList = carDao.readByManufacturer(manufacturer);

		return "json_list_by_manufacturer";
	}

	public List<Car> getCarList()
	{
		return carList;
	}

	public void setCarList(List<Car> carList)
	{
		this.carList = carList;
	}	

	public String getManufacturerName()
	{
		return manufacturerName;
	}

	public void setManufacturerName(String manufacturerName)
	{
		this.manufacturerName = manufacturerName;
	}

}
